home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_casm / snpd9611.zip / DELAY.C < prev    next >
Text File  |  1996-11-24  |  804b  |  32 lines

  1. .I 0 5
  2. /* +++Date last modified: 06-Sep-1996 */
  3.  
  4. /*
  5. **  DELAY.C - A portable time delay compatible with Borland's and Watcom's
  6. **            delay() function.
  7. .D 1 3
  8. .I 7 3
  9. #if (!defined(__WATCOMC__) && !defined(__TURBOC__)) || (defined(__TURBOC__) \
  10.       && (defined(_Windows) && !defined(__DPMI16) && !defined(__DPMI32__)))
  11.  
  12. .I 10 15
  13. #ifndef  CLOCKS_PER_SEC                   /* CLOCKS_PER_SEC is ANSI/ISO */
  14.  #define CLOCKS_PER_SEC CLK_TCK
  15. #endif
  16.  
  17. void delay(unsigned short msec)
  18. {
  19.       clock_t t0;
  20.       unsigned long diff = 0L;
  21.  
  22.       for (t0 = clock(); diff < (unsigned long)msec; )
  23.       {
  24.             diff  = (unsigned long)(clock() - t0);
  25.             diff *= 1000L;
  26.             diff /= CLOCKS_PER_SEC;
  27.       }
  28. .D 11 9
  29. .I 42 2
  30.  
  31. #endif /* Not Watcom or Borland */
  32.